//
//  KINGStatusCellHeaderView.swift
//  肉荣微博
//
//  Created by king on 15/8/2.
//  Copyright © 2015年 king. All rights reserved.
//

import UIKit
import SDWebImage

class KINGStatusCellHeaderView: UIView {
    var status: KINGStatuses? {
        didSet{
            iconView.sd_setImageWithURL(status?.my_user?.imageUrl)
            titleLabel.text = status?.my_user?.name
            timeLabel.text = "刚刚"
            //sourceLabel.text = status?.source
            sourceLabel.text = "来自村里的姑娘"
            memberView.image = status?.my_user?.verifiedImage
            vipView.image = status?.my_user?.mbrankImage
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //添加并布局子控件
    private func setupUI() {
        addSubview(iconView)
        addSubview(titleLabel)
        addSubview(timeLabel)
        addSubview(sourceLabel)
        addSubview(vipView)
        addSubview(memberView)
        
        iconView.ff_AlignInner(type: ff_AlignType.TopLeft, referView: self, size: CGSize(width: 35, height: 35), offset: CGPoint(x: statusCellContolMargin, y: statusCellContolMargin))
        titleLabel.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: iconView, size: nil, offset: CGPoint(x: statusCellContolMargin, y: 0))
        timeLabel.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: iconView, size: nil, offset: CGPoint(x: statusCellContolMargin, y: 0))
        sourceLabel.ff_AlignHorizontal(type: ff_AlignType.BottomRight, referView: timeLabel, size: nil, offset: CGPoint(x: statusCellContolMargin, y: 0))
        vipView.ff_AlignHorizontal(type: ff_AlignType.TopRight, referView: titleLabel, size: CGSize(width: statusCellContolMargin * 2.0, height: statusCellContolMargin * 2.0), offset: CGPoint(x: statusCellContolMargin, y: 0))
        memberView.ff_AlignInner(type: ff_AlignType.BottomRight, referView: iconView, size: CGSize(width: statusCellContolMargin * 2.0, height: statusCellContolMargin * 2.0), offset: CGPoint(x: statusCellContolMargin, y: statusCellContolMargin))
    }
    
    //MARK: - 懒加载控件
    lazy var iconView:UIImageView = {
        let icon = UIImageView(image: UIImage(named: "tabbar_compose_button"))
        return icon
    }()
    lazy var titleLabel:UILabel = UILabel(color: UIColor.darkGrayColor(), fontSize: 13.0)
    lazy var timeLabel:UILabel = UILabel(color: UIColor.darkGrayColor(), fontSize: 10.0)
    lazy var sourceLabel:UILabel = UILabel(color: UIColor.darkGrayColor(), fontSize: 10.0)
    lazy var memberView:UIImageView = UIImageView()
    lazy var vipView:UIImageView = UIImageView()

}
